package com.jdb.loan.provider.service.impl;

import com.guns21.result.domain.Result;
import com.guns21.support.service.BaseCommandService;
import com.jdb.loan.provider.entity.LoanCategoryDO;
import com.jdb.loan.provider.entity.LoanDO;
import com.jdb.loan.provider.repository.LoanCategoryRepository;
import com.jdb.loan.provider.repository.LoanRepository;
import com.jdb.loan.provider.service.LoanCommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoanCommandServiceImpl extends BaseCommandService implements LoanCommandService {


    @Autowired
    private LoanRepository loanRepository;
    @Autowired
    private LoanCategoryRepository loanCategoryRepository;

    @Override
    public Result<LoanDO> save(LoanDO loan) {

        loanRepository.save(loan);
        //TODO send event
        return Result.success();
    }

    @Override
    public Result<LoanCategoryDO> saveCategory(LoanCategoryDO loanCategoryDTO) {
        loanCategoryRepository.save(loanCategoryDTO);
        //TODO send event
        return Result.success();
    }
}
